package cn.wizzer.app.task.commons.ext.quartz.job;

import cn.wizzer.framework.util.ScriptUtil;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

@IocBean
public class ShellJob implements Job {

    @Inject
    private PropertiesProxy conf;

    private static final Log log = Logs.get();
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
       try{
           JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
           String script =jobDataMap.getString("script");
           ScriptUtil.execute(script);
       }catch (Exception e){
           log.error(e.getMessage());
       }
    }
}
